
<?php 
require_once 'models/models_thanhtoan.php';
$tt=new models_thanhtoan();  
if (isset($_SESSION['cart'])) {
//?>
<div id="sanpham_right">
           	    <div id="title_right">
            		<p id="title_right_left"></p>
            		<div id="title_right_center">
            		  <p class="chu_title">GIỎ HÀNG CỦA BẠN</p>
            		</div>
           			<p id="title_right_right"></p>
             	</div>
                <div id="noidung_right">
		<form name="update" action="" method="post">
			<table width="560px" cellspacing="0" cellpadding="0" border="1">
				<tr class="bg_cart_giohang" height="30px">
					<th width="5%" class="table_cart" align="center">STT</th>
					<th width="25%" class="table_cart" align="center">Tên hàng</th>
					<th width="15%" class="table_cart" align="center">Số lượng</th>
					<th width="15%" class="table_cart" align="center">Đơn giá</th>
					<th width="15%" class="table_cart" align="center">Thành tiền</th>
				</tr>
				<?php
				$i = 1;
				$sumTotal = 0;
			
				foreach ($_SESSION['cart'] as $key => $value) {
						$mh=$tt->getmathang($key);
					?>
				<tr height="30px">
					
					<td class="table_cart" align="center"><?php echo $i; ?></td>
					<td class="table_cart" align="left"><?php echo $value['tenmh'];?></td>
					<td class="table_cart" align="center"><?php  if( $mh['SoLuong']>=$value['soluong'])
                                 {
                                 	echo $value['soluong'];
                                 }
                                 else 
                                 {
                                 	echo $value['soluong']=$mh['SoLuong'];
                                 	
                                 }?>
					</td>
					<td class="table_cart" align="center"><?php echo number_format($value['gia']);?></td>
					<td class="table_cart" align="center"><?php
					$total = $value['soluong'] * $value['gia'];
					echo number_format($total);
					?>
					</td>
					
				</tr>
				<?php
				$sumTotal += $total;
				$i++;
				}
				?>
				<tr height="30px">
					<th class="table_cart" colspan="4" align="center" valign="top"
						scope="row">Tổng cộng</th>
					<th class="table_cart" align="center" valign="top"><?php echo number_format($sumTotal); ?> VNĐ
					</th>
					
				</tr>

			</table>
			
		</form>
	</div>
	<?php
} 

if(!isset($_SESSION['username']))
{?>
<script type="text/javascript" src="public/jquery-validate/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="public/jquery-validate/jquery.validate.min.js"></script>
	<script type="text/javascript" src="public/jquery-validate/localization/messages_vi.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#contact").validate({
				errorElement: "span", //Thành phần HTML hiện thông báo lỗi
				//Sử dụng tùy chọn rules cho những validate không hỗ trợ bởi class name
				rules: {
					password: {
						equalTo: "#cpassword" //So sánh với trường cpassword với thành trường có id là password
					},
					cemail: {
						equalTo: "#email" //So sánh với trường cemail với thành trường có id là email
					},
					<?php
					echo $_SESSION['security_code'];?>:{
						equalTo: "#txtCaptcha" 
					},
					min_field: { min: 5 }, //Giá trị tối thiểu
					max_field: { max : 10 }, //Giá trị tối đa
					range_field: { range: [4,10] }, //Giá trị trong khoảng từ 4 - 10
					rangelength_field: { rangelength: [4,10] } //Chiều dài chuỗi trong khoảng từ 4 - 10 ký tự
				}
			});
		});
	</script>
<div id="title_right">
            		<p id="title_right_left"></p>
            		<div id="title_right_center">
            		  <p class="chu_title">THÔNG TIN KHÁCH HÀNG</p>
            		</div>
           			<p id="title_right_right"></p>
             	</div>

	
		<form id="contact" method="post" action="" enctype="multipart/form-data" class="contact-form" >
		
		<table class="table3">

				<tr>

					<td>Họ và tên<span class="rq"> * </span>:</td>

					<td><input name="txthovaten" type="text" id="txthovaten"
							class="required" tabindex="5" style="background:#FFF" /></td>

				</tr>
				<tr>

					<td>Email<span class="rq"> * </span>:</td>

					<td><input class="required email" id="email" name="txtmail" type="text" class="text" tabindex="4" style="background:#FFF" /></td>

				</tr>

				<tr>

					<td>Điện thoại<span class="rq"> * </span>:</td>

					<td><input id="mobi" class="required" maxlength="12" name="txtdienthoai" type="text" class="text" tabindex="5" style="background:#FFF" /></td>

				</tr>

				<tr>

					<td>Địa chỉ<span class="rq"> * </span>:</td>

					<td><textarea name="txtdiachi" cols="20" rows="5" id="txtdiachi"
							class="required" style="background:#FFF"></textarea>
					</td>

				</tr>
                <tr>
					<td>Mã bảo vệ:</td>
					<td>
					<img src="public/hinhanh/capcha.php" />
					</td>
				</tr>
				<tr>
					<td>Nhập mã bảo vệ<span class="rq"> * </span>:</td> 
					<td><input type="text" name="txtCaptcha" maxlength="10"
						size="20" class="required" style="background:#FFF"/>
					</td>
					</tr>
			<tr>
				
					<td align="center" colspan="2">
                    <input name="" type="submit" value="" class="btTxt submit" style="background: url('public/hinhanh/mua.jpg');height: 28px;width: 83px"/>
                    
					</td>

				</tr>


			</table>

		</form>
	</div>
	

<?php 
}
else 
{
	if(isset($kh)){
//var_dump($data);	
//var_dump($kh)	?>
<div id="title_right">
            		<p id="title_right_left"></p>
            		<div id="title_right_center">
            		  <p class="chu_title">THÔNG TIN KHÁCH HÀNG</p>
            		</div>
           			<p id="title_right_right"></p>
             	</div>
<form action="" method="post" name="muahang">
  <table class="table2">
      <tr height="30px;">
      <td >Họ và tên:</td>
      <td width=""><?php echo $kh['TenKH'];?></td>
    </tr>
    <tr height="30px;">
      <td>Địa chỉ:</td>
      <td><?php echo $kh['DiaChi'];?></td>
    </tr>
    <tr height="30px;">
      <td>Số điện thoại:</td>
      <td><?php echo $kh['SDT'];?></td>
    </tr>
    <tr>
    <td>Email:</td>
    <td><?php echo $kh['Email'];?></td>
    </tr>
    <tr>
					<td>Mã bảo vệ:</td>
					<td>
					<img src="public/hinhanh/capcha.php" />
					</td>
				</tr>
				<tr>
					<td>Nhập mã bảo vệ<span class="rq"> * </span>:</td> 
					<td><input type="text" name="txtCaptcha" maxlength="10"
						size="20" class="required" style="background:#FFF"/>
					</td>
					</tr>
			<tr>
				
					<td align="center" colspan="2">
                    <input name="" type="submit" value="" class="btTxt submit" style="background: url('public/hinhanh/mua.jpg');height: 28px;width: 83px"/>
                    <input name="" type="reset" id="" value="" style="background: url('public/hinhanh/lamlai.jpg');height: 28px;width: 83px" />
					</td>

				</tr>
  
  
  
  </table>
	
</form>
</div>
<?php
}}


?>


